package org.ichihamigua.video.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.ichihamigua.common.framework.entity.Result;
import org.ichihamigua.common.video.entity.VideoBulletEntity;
import org.ichihamigua.common.video.entity.VideoBulletLikeEntity;
import org.ichihamigua.video.service.VideoBulletLikeService;
import org.ichihamigua.video.service.VideoBulletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author rainkyzhong
 * @date 2023/10/29 0:57
 */
@RequestMapping("/video_bullet")
@RestController
@Slf4j
public class VideoBulletController {
    @Autowired
    private VideoBulletService videoBulletService;
    @Autowired
    private VideoBulletLikeService videoBulletLikeService;

    //TODO 发表弹幕接口
    @PostMapping("/video_bullet")
    public Result<?> saveVideoBullet(@RequestBody VideoBulletEntity videoBulletEntity){
        Long userId = 1L;
        videoBulletService.save(videoBulletEntity);
        return Result.success(videoBulletEntity);
    }

    //TODO 获取视频弹幕接口（不是全部获取出来，如果弹幕很多，取出部分）
    @GetMapping("/{videoId}")
    public Result<?> getVideoBullet(@PathVariable Long videoId){
        Long userId = 1L;
        return videoBulletService.getBullet(videoId);
    }

    //TODO 举报弹幕接口

    //TODO 删除弹幕接口
    @DeleteMapping("/delete/{id}")
    public Result<?> deleteVideoBullet(@PathVariable Long id){
        if(id == null){
            return Result.fail("请求异常");
        }
        Long userId = 1L;
        return videoBulletService.deleteBullet(userId, id);
    }

    //TODO 点赞弹幕接口
    @PostMapping("/video_bullet_like")
    public Result<?> saveVideoBulletLike(@RequestBody VideoBulletLikeEntity videoBulletLikeEntity){
        Long userId = 1L;
        videoBulletLikeService.save(videoBulletLikeEntity);
        return Result.success(videoBulletLikeEntity);
    }
}
